package ord2.database;

import ord2.core.AbstractQuery;
import ord2.core.Parameter;
import ord2.core.Result;

/**
 * Specifies a way to connect with some database passing some parameters if necessary.
 * This interface is used to retrieve some data from a database.
 *
 * @author José Ivan
 * @author Edviges
 *
 */
public interface ParametricDatabaseConnector extends DatabaseConnector {
    
    /**
     * Does the connection with database passing some parameters.
     * @param pars Parameters used in connection
     * @throws Throwable If any problem occurs
     */
    void connect(Parameter[] pars) throws Throwable;
    
    /**
     * Does a query in database with some parameters.
     * @param query Query that will be used
     * @param <Q> Type of encapsulated object by query
     * @param pars Array containg parameters to be used in query
     * @throws Throwable if any error occurs
     * @return Array containg results from database
     * @see AbstractQuery
     * @see Result
     */
    <Q> Result[] query(AbstractQuery<Q> query, Parameter[] pars) throws Throwable;
}
